Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spiral target shape #192

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

nickc6424
Copy link
Contributor

Fixes #177

Describe your changes
Added Spiral target shape

Checklist

  • Test cases have been modified/added to cover any code changes.
  • Docstrings have been modified/created for any code changes.
  • All linting and formatting checks pass (see the contributing guidelines for more information).

@github-actions github-actions bot added testing Relating to the testing suite shapes Work relating to shapes module labels Jul 13, 2024
@stefmolin stefmolin changed the title Issue 177 spiral target Add spiral target shape Jul 13, 2024
@nickc6424 nickc6424 marked this pull request as draft July 13, 2024 14:06
@stefmolin stefmolin added this to the 0.3.0 milestone Jul 13, 2024
@nickc6424 nickc6424 marked this pull request as ready for review July 13, 2024 14:13
Copy link

codecov bot commented Jul 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.42%. Comparing base (51b8d26) to head (dbc4e76).
Report is 18 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #192   +/-   ##
=======================================
  Coverage   98.42%   98.42%           
=======================================
  Files          43       43           
  Lines        1775     1782    +7     
  Branches      358      357    -1     
=======================================
+ Hits         1747     1754    +7     
  Misses         25       25           
  Partials        3        3           
Files with missing lines Coverage Δ
src/data_morph/shapes/factory.py 100.00% <ø> (ø)
src/data_morph/shapes/points.py 100.00% <100.00%> (ø)
tests/shapes/test_points.py 100.00% <100.00%> (ø)

Copy link
Owner

@stefmolin stefmolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks incredible on the soccer dataset – thanks @nickc6424! A few small things to address here.

Comment on lines +329 to +332
Notes
-----
The formula for a spiral can be found here:
https://en.wikipedia.org/wiki/Archimedean_spiral
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you!

# Number of rotations
num_rotations = 3

t = np.linspace(0, 1, num=200)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment for this one too?

Comment on lines +352 to +353
x = (t * radius) * np.cos(2 * num_rotations * math.pi * t) + cx
y = (t * radius) * np.sin(2 * num_rotations * math.pi * t) + cy
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we modify this to start at the top when the y range is bigger than the x range? For example, on the dog shape, the outermost point of the spiral would be at the dog's head instead of way off to the right.

Screenshot 2024-07-16 at 6 53 12 PM

Comment on lines +352 to +353
x = (t * radius) * np.cos(2 * num_rotations * math.pi * t) + cx
y = (t * radius) * np.sin(2 * num_rotations * math.pi * t) + cy
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
x = (t * radius) * np.cos(2 * num_rotations * math.pi * t) + cx
y = (t * radius) * np.sin(2 * num_rotations * math.pi * t) + cy
x = (t * radius) * np.cos(2 * num_rotations * np.pi * t) + cx
y = (t * radius) * np.sin(2 * num_rotations * np.pi * t) + cy

@@ -1,6 +1,7 @@
"""Shapes that are composed of points."""

import itertools
import math
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stick with numpy for this.

Suggested change
import math

Class for the spiral shape.

.. plot::
:scale: 100
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep all the plots the same size:

Suggested change
:scale: 100
:scale: 75

# Number of rotations
num_rotations = 3

t = np.linspace(0, 1, num=200)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two other thoughts here:

  1. Can we use fewer points? This would speed up the distance calculations.
  2. The points are farther apart as the spiral grows. Can we reduce the density at the center and fill in the outer parts better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shapes Work relating to shapes module testing Relating to the testing suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add spiral target shape
3 participants